# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html
import codecs


class LianjiaPipeline(object):
    def __init__(self):
        self.file = codecs.open('communities.csv', 'wb', 'utf-8')

    def process_item(self, item, spider):
        line = item['name'] + '\t' + item['geohash'] + '\t' + str(item['lat']) + '\t' \
               + str(item['lng']) + '\t' + item['price'] + '\n'
        self.file.write(line)
        return item
